package yanyan.com.tochar.utils;

import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import yanyan.com.tochar.R;

public class UiUtil {

    /**
     * 初始化下拉框
     * @param spinner
     * @param list
     */
    public static void initSpinner(Spinner spinner, String[] list, Context context){
        List<String> selects= Arrays.asList(list);
        ArrayAdapter<String> selectAd=new ArrayAdapter<String>(context, R.layout.support_simple_spinner_dropdown_item,selects);
        selectAd.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
        spinner.setAdapter(selectAd);
    }
}
